<?php

namespace Admin\Model;
use Think\Model;

/**
 * 站内信模型
 */
class MessageModel extends Model
{
	/**
	 * 发送一条信息
	 * @param [array] $data [数据]
	 * @return 新记录id
	 * @author qlj
	 */
	public function addMessage($data){
		if (empty($data['time'])) {
			$data['time'] = time();
		}
		return $this -> add($data);
	}		/**	 * lkl循环替换数据	 */	public function updateData($data){		foreach ($data as &$value) {			$value['sname'] 	= $this->findename($value['sid']);			$value['rname'] 	= $this->findename($value['rid']);			$value['time']   = date('Y/m/d H:i:s',$value['time']);		};		return $data;	}		/**	 * lkl循环替换数据	 */	public function findename($id){		 $data = D('UserMember') ->field('nickname') ->where(array('id' => $id)) ->find();		return $data['nickname'];	}
}